package com.cheng.mybatis.serviceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cheng.mybatis.domain.User;
import com.cheng.mybatis.domain.UserExample;
import com.cheng.mybatis.mapper.UserMapper;
import com.cheng.mybatis.service.UserService;

@Service("userService")
public class UserServiceImpl implements UserService {

	@Autowired
	private UserMapper mapper;

	public User login(User user) {
		UserExample example = new UserExample();
		example.createCriteria().andNameEqualTo(user.getName()).andPasswordEqualTo(user.getPassword());
		List<User> users = mapper.selectByExample(example);
		if (users.size() > 0 && users != null) {
			return users.get(0);
		}
		return null;

	}

}
